package com.ColonyCount.Image;

public class Image8 {
	public byte[] pixels;
	private int width;
	private int height;
	
	public Image8(int width, int height)
	{
		this.width = width;
		this.height = height;
		pixels = new byte[width*height];
	}
	
	public int getPixelValue(int x, int y)
	{
		int offset = x + y*width;
		return pixels[offset] & 0xFF;
	}
	
	public void setPixelValue(int x, int y, int value)
	{
		int offset = x + y*width;
		pixels[offset] = (byte)value;
	}
	
	public Image8 duplicate()
	{
		Image8 doublicate = new Image8(width, height);
		int count = pixels.length;
		 byte[] targetPixels = doublicate.getPixels();
		for(int i=0;i<count;i++)
		{
			targetPixels[i] = pixels[i];
		}
		return doublicate;
	}
	
	public int getWidth()
	{
		return width;
	}
	
	public int getHeight()
	{
		return height;
	}
	
	public byte[] getPixels()
	{
		return pixels;
	}
	
	public void clear()
	{
		int count = pixels.length;
		for(int i=0;i<count;i++)
		{
			pixels[i] = 0;
		}
	}
}
